using System.Collections.Generic;
using System.Linq;

namespace GraphMyCode.Web
{
	public class ColorService
	{
		private static readonly List<string> Lookup = new List<string>
		                                                    	{ 
		                                                    		//new KeyValuePair<string, string>("#ffffe4c4", "Bisque"),
		                                                    		//new KeyValuePair<string, string>("#ffffebcd", "BlanchedAlmond"),
		                                                    		"Blue",
		                                                    		//new KeyValuePair<string, string>("#ff8a2be2", "BlueViolet"),
		                                                    		"Gold",
		                                                    		"Green",
		                                                    		//new KeyValuePair<string, string>("#ffdeb887", "BurlyWood"),
		                                                    		//new KeyValuePair<string, string>("#ff5f9ea0", "CadetBlue"),
		                                                    		//new KeyValuePair<string, string>("#ff7fff00", "Chartreuse"),
		                                                    		//new KeyValuePair<string, string>("#ffd2691e", "Chocolate"),
		                                                    		//new KeyValuePair<string, string>("#ffff7f50", "Coral"),
		                                                    		//new KeyValuePair<string, string>("#ff6495ed", "CornflowerBlue"),
		                                                    		//new KeyValuePair<string, string>("#fffff8dc", "Cornsilk"),
		                                                    		//"Crimson",
		                                                    		"Cyan",
		                                                    		"Red",
		                                                    		//"DarkBlue",
		                                                    		//new KeyValuePair<string, string>("#ff008b8b", "DarkCyan"),
		                                                    		"DarkGray",
		                                                    		"DarkGreen",
		                                                    		"DarkKhaki",
		                                                    		"DarkGoldenrod",
		                                                    		"DarkMagenta",
		                                                    		"DarkOliveGreen",
		                                                    		"DarkOrange",
		                                                    		"DarkOrchid",
		                                                    		"DarkRed",
		                                                    		"DarkSalmon",
		                                                    		"Brown",
		                                                    		//new KeyValuePair<string, string>("#ff8fbc8f", "DarkSeaGreen"),
		                                                    		"DarkSlateBlue",
		                                                    		"DarkSlateGray",
		                                                    		"DarkTurquoise",
		                                                    		"DarkViolet",
		                                                    		"DeepPink",
																	"Beige",
		                                                    		//new KeyValuePair<string, string>("#ff00bfff", "DeepSkyBlue"),
		                                                    		"DimGray",
		                                                    		"DodgerBlue",
		                                                    		//new KeyValuePair<string, string>("#ffb22222", "Firebrick"),
		                                                    		//new KeyValuePair<string, string>("#fffffaf0", "FloralWhite"),
		                                                    		//new KeyValuePair<string, string>("#ff228b22", "ForestGreen"),
		                                                    		//new KeyValuePair<string, string>("#ffdcdcdc", "Gainsboro"),
		                                                    		//new KeyValuePair<string, string>("#fff8f8ff", "GhostWhite"),
		                                                    		//new KeyValuePair<string, string>("#ffdaa520", "Goldenrod"),
		                                                    		"Gray",
		                                                    		//new KeyValuePair<string, string>("#ffadff2f", "GreenYellow"),
		                                                    		//new KeyValuePair<string, string>("#fff0fff0", "Honeydew"),
		                                                    		//new KeyValuePair<string, string>("#ffff69b4", "HotPink"),
		                                                    		//new KeyValuePair<string, string>("#ffcd5c5c", "IndianRed"),
		                                                    		"Indigo",
		                                                    		"Ivory",
		                                                    		"Khaki",
		                                                    		//new KeyValuePair<string, string>("#ffe6e6fa", "Lavender"),
		                                                    		//new KeyValuePair<string, string>("#fffff0f5", "LavenderBlush"),
																	//new KeyValuePair<string, string>("#ff7cfc00", "LawnGreen"),
																	//new KeyValuePair<string, string>("#fffffacd", "LemonChiffon"),
																	//new KeyValuePair<string, string>("#ff00ff00", "Lime"),
																	//new KeyValuePair<string, string>("#ff32cd32", "LimeGreen"),
																	//new KeyValuePair<string, string>("#fffaf0e6", "Linen"),
																	//new KeyValuePair<string, string>("#ffff00ff", "Magenta"),
																	//new KeyValuePair<string, string>("#ff800000", "Maroon"),
																	//new KeyValuePair<string, string>("#ff66cdaa", "MediumAquamarine"),
																	//new KeyValuePair<string, string>("#ff0000cd", "MediumBlue"),
																	//new KeyValuePair<string, string>("#ffba55d3", "MediumOrchid"),
																	//new KeyValuePair<string, string>("#ff9370db", "MediumPurple"),
																	//new KeyValuePair<string, string>("#ff3cb371", "MediumSeaGreen"),
																	//new KeyValuePair<string, string>("#ff7b68ee", "MediumSlateBlue"),
																	//new KeyValuePair<string, string>("#ff00fa9a",
																	//                                 "MediumSpringGreen"),
																	//new KeyValuePair<string, string>("#ff48d1cc", "MediumTurquoise"),
																	//new KeyValuePair<string, string>("#ffc71585", "MediumVioletRed"),
																	//new KeyValuePair<string, string>("#ff191970", "MidnightBlue"),
																	//new KeyValuePair<string, string>("#fff5fffa", "MintCream"),
																	//new KeyValuePair<string, string>("#ffffe4e1", "MistyRose"),
																	//new KeyValuePair<string, string>("#ffffe4b5", "Moccasin"),
																	//new KeyValuePair<string, string>("#ffffdead", "NavajoWhite"),
																	//new KeyValuePair<string, string>("#ff000080", "Navy"),
																	//new KeyValuePair<string, string>("#fffdf5e6", "OldLace"),
		                                                    		"Olive",
		                                                    		//new KeyValuePair<string, string>("#ff6b8e23", "OliveDrab"),
		                                                    		"Orange",
		                                                    		//new KeyValuePair<string, string>("#ffff4500", "OrangeRed"),
		                                                    		//new KeyValuePair<string, string>("#ffda70d6", "Orchid"),
		                                                    		//new KeyValuePair<string, string>("#ffeee8aa", "PaleGoldenrod"),
		                                                    		//new KeyValuePair<string, string>("#ff98fb98", "PaleGreen"),
		                                                    		//new KeyValuePair<string, string>("#ffafeeee", "PaleTurquoise"),
		                                                    		//new KeyValuePair<string, string>("#ffdb7093", "PaleVioletRed"),
		                                                    		//new KeyValuePair<string, string>("#ffffefd5", "PapayaWhip"),
		                                                    		//new KeyValuePair<string, string>("#ffffdab9", "PeachPuff"),
		                                                    		//new KeyValuePair<string, string>("#ffcd853f", "Peru"),
		                                                    		//new KeyValuePair<string, string>("#ffffc0cb", "Pink"),
		                                                    		//new KeyValuePair<string, string>("#ffdda0dd", "Plum"),
		                                                    		"PowderBlue",
		                                                    		"Purple",
		                                                    		//new KeyValuePair<string, string>("#ffbc8f8f", "RosyBrown"),
		                                                    		//new KeyValuePair<string, string>("#ff4169e1", "RoyalBlue"),
		                                                    		//new KeyValuePair<string, string>("#ff8b4513", "SaddleBrown"),
		                                                    		//new KeyValuePair<string, string>("#fffa8072", "Salmon"),
		                                                    		//new KeyValuePair<string, string>("#fff4a460", "SandyBrown"),
		                                                    		//new KeyValuePair<string, string>("#ff2e8b57", "SeaGreen"),
		                                                    		//new KeyValuePair<string, string>("#fffff5ee", "SeaShell"),
		                                                    		//new KeyValuePair<string, string>("#ffa0522d", "Sienna"),
		                                                    		"Silver",
		                                                    		//new KeyValuePair<string, string>("#ff87ceeb", "SkyBlue"),
		                                                    		//new KeyValuePair<string, string>("#ff6a5acd", "SlateBlue"),
		                                                    		//new KeyValuePair<string, string>("#ff708090", "SlateGray"),
		                                                    		//new KeyValuePair<string, string>("#fffffafa", "Snow"),
		                                                    		//new KeyValuePair<string, string>("#ff00ff7f", "SpringGreen"),
		                                                    		//new KeyValuePair<string, string>("#ff4682b4", "SteelBlue"),
		                                                    		//new KeyValuePair<string, string>("#ffd2b48c", "Tan"),
		                                                    		//new KeyValuePair<string, string>("#ff008080", "Teal"),
		                                                    		//new KeyValuePair<string, string>("#ffd8bfd8", "Thistle"),
		                                                    		"Tomato",
		                                                    		//new KeyValuePair<string, string>("#ffffff", "Transparent"),
		                                                    		//new KeyValuePair<string, string>("#ff40e0d0", "Turquoise"),
		                                                    		"Violet",
		                                                    		//new KeyValuePair<string, string>("#fff5deb3", "Wheat"),
		                                                    		//new KeyValuePair<string, string>("#ffffffff", "White"),
		                                                    		//new KeyValuePair<string, string>("#fff5f5f5", "WhiteSmoke"),
		                                                    		"Yellow",
		                                                    		//new KeyValuePair<string, string>("#ff9acd3", "YellowGreen")
		                                                    	};

		readonly Dictionary<object, string> colorMap = new Dictionary<object, string>();

		public string GetColorByObject(object type)
		{
			if (colorMap.ContainsKey(type))
				return colorMap[type];

			var color = Lookup.FirstOrDefault(c => !colorMap.Values.Contains(c));
			if (!string.IsNullOrEmpty(color))
			{
				colorMap.Add(type, color);
				return color;
			}

			return "White";
		}
	}
}